package com.guli.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileFilter;

/**
 * @author XiaoHua666
 * @date 2019/8/18
 */
public class FileUtil {
    public static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class);

    public boolean  getFileNames(String dirPath) {

        // 如果sPath不以文件分隔符结尾，自动添加文件分隔符
        if (!dirPath.endsWith(File.separator)) {
            dirPath = dirPath + File.separator;
        }
        File dirFile = new File(dirPath);
        // 如果dir对应的文件不存在，或者不是一个目录，则退出
        if (!dirFile.exists() || !dirFile.isDirectory()) {
            return false;
        }
        boolean flag = true;
        File[] files = dirFile.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                if (pathname.isFile()) {
                    return true;
                }
                return false;
            }
        });// 获得传入路径下的所有文件

        for (int i = 0; i < files.length; i++) {
            if (files[i].isFile()) {
                String fileName = files[i].getName();
                String realFileName = fileName.substring(0, fileName.lastIndexOf("."));
                System.out.println(realFileName);

            }
        }

        return true;


    }

    public void readFile(){

    }


  public static void main(String[] args){
      String basePackage = "aaa";
      FileUtil fileUtil = new FileUtil();
      fileUtil.getFileNames("E:\\JAVA\\视频教程");


  }

}
